package com.sleepapp.controller.module;


import com.sleepapp.annotation.SaUserCheckLogin;
import com.sleepapp.service.RedemptionRecordService;
import com.sleepapp.utils.AjaxResult;
import com.sleepapp.vo.PageQueryInfo;
import com.sleepapp.vo.PageQueryParamVo;
import com.sleepapp.vo.RecordQueryAllVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 兑换记录表 前端控制器
 * </p>
 *
 * @author 
 * @since 2025-03-13
 */
@RestController
@RequestMapping("/redemptionRecord")
public class RedemptionRecordController {

    @Autowired
    private RedemptionRecordService redemptionRecordService;

    /**
     * 添加兑换记录
     * @param id
     * @folder 商品
     */
    @PostMapping("/add/{id}")
    @SaUserCheckLogin
    public AjaxResult<Void> add(@PathVariable Long id) {
        return redemptionRecordService.add(id);
    }

    /**
     * 获取兑换记录
     * @param pageQueryParamVo
     * @folder 兑换记录
     */
    @GetMapping("/getAll")
    @SaUserCheckLogin
    public AjaxResult<PageQueryInfo<List<RecordQueryAllVo>>> getAll(@ModelAttribute PageQueryParamVo pageQueryParamVo) {
        return AjaxResult.success(redemptionRecordService.getAll(pageQueryParamVo));
    }
}

